export const schema = {
    type: "page",
    title: "机构列表",
    toolbar: {
        visibleOn: 'acl.can("org:create")',
        type: "button",
        actionType: "link",
        icon: "fa fa-plus pull-left",
        level: "success",
        label: "创建机构",
        link: "/org/create"
    },
    body: {
        type: "crud",
        api: "get:/api/org",
        columnsTogglable: false,
        showHeader: false,
        filter: {
            title: "",
            panelClassName: 'm-b-none bg-gd no-border',
            bodyClassName: 'wrapper-sm',
            submitText: "",
            controls: [
                {
                    type: "text",
                    name: "name",
                    placeholder: "输入机构名称",
                    className: 'm-b-none',
                    addOn: {
                        type: "submit",
                        label: "搜索",
                        className: "btn-primary"
                    }
                }
            ]
        },
        columns: [
            {
                name: "id",
                label: "机构ID",
                width: 50
            },
            /*{
                "label": "机构微信平台接口"
            },*/
            {
                name: "name",
                label: "机构名称",
                type: "tpl",
                tpl: "<a data-link='/org/view/${id}'>${name}</a>"
            },
            {
                name: "name",
                label: "团队数",
                type: "tpl",
                tpl: "<a data-link='/team/list?org_id=${id}'>${team_count}</a>"
            },
            {
                name: "name",
                label: "项目数",
                type: "tpl",
                tpl: "<a data-link='/project/list?org_id=${id}'>${project_count}</a>"
            },

            {
                label: "志愿者数",
                name: "volunteer_count",
                type: "tpl",
                tpl: "<a data-link='/volunteer/list?org_id=${id}'>${volunteer_count}</a>"
            },

            {
                name: "reward_count",
                label: "志愿时长"
            },

            {
                label: "操作",
                type: "operation",
                visibleOn: "acl.can('org:create')",
                width: 180,
                buttons: [
                    {
                        type: "button",
                        size: "xs",
                        label: "禁用",
                        level: "warning",
                        confirmText: "确定要禁用？",
                        actionType: "ajax",
                        api: "/api/org/offline/$id",
                        visibleOn: "!data.in_blacklist"
                    },

                    {
                        type: "button",
                        size: "xs",
                        label: "恢复",
                        level: "success",
                        confirmText: "确定要恢复？",
                        actionType: "ajax",
                        api: "/api/org/online/$id",
                        visibleOn: "data.in_blacklist"
                    },

                    {
                        type: "button",
                        size: "xs",
                        level: "info",
                        label: "编辑",
                        actionType: "link",
                        link: "/org/edit/${id}"
                    },

                    // {
                    //     type: "button",
                    //     size: "xs",
                    //     label: "删除",
                    //     level: "danger",
                    //     confirmText: "确定要删除？",
                    //     actionType: "ajax",
                    //     api: "delete:/api/org/$id"
                    // }
                ]
            }
        ]
    }
};
